/*
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef EPUB_DOCUMENT_H_
#define EPUB_DOCUMENT_H_

//External includes
#include <boost/shared_ptr.hpp>
#include <list>

// Abiword includes
#include <ut_string.h>
#include <ut_string_class.h>
#include <pd_Document.h>

// EPUB includes
#include "EPUB_Element.h"
#include "EPUB_Style.h"
#include "EPUB_EmbeddedFile.h"

class EPUB_Document;
typedef boost::shared_ptr<EPUB_Document> EPUB_Shared_Document;

/**
 * Class for storing EPUB document data. Since we need only 1 instance of it during export
 * process it will implement Singleton pattern
 */
class EPUB_Document
{
	public:
	/**
	 * Returns instance of EPUB document
	 */
	static EPUB_Shared_Document getInstance();
	/**
	 * Returns new instance of EPUB document and destroys previous
	 */
	static EPUB_Shared_Document getNewInstance();
	UT_UTF8String *getTitle();
	UT_UTF8String *getAuthor();

	EPUB_Shared_Element getDocumentRoot();
	/**
	 * Returns pointer to document <body> dom element
	 */
	EPUB_Shared_Element getDocumentBody();

	std::list<EPUB_Shared_EmbeddedFile> &getFiles();
	/**
	 * Loads metadata from the specified document
	 */
	void loadMetadata(PD_Document *pDoc);
	void addFile(EPUB_Shared_EmbeddedFile file);

private:
	EPUB_Document();
	static EPUB_Shared_Document s_instance;
	/**
	 * Root element of the document
	 */
	EPUB_Shared_Element m_pRoot;
	/**
	 * Vector with document styles
	 */
	std::list<EPUB_Shared_Style> m_styles;
	std::list<EPUB_Shared_EmbeddedFile> m_files;


	UT_UTF8String *m_pTitle;
	UT_UTF8String *m_pAuthor;

};



#endif /* EPUB_DOCUMENT_H_ */
